<% if (addOnEnabled.start) { ignoreFile() } %><% if (codeRouter) {
  
/// Code Router

%>import {
  Outlet,
  RouterProvider,
  createRootRoute,
  createRoute,
  createRouter,
} from "@tanstack/solid-router";
import { TanStackRouterDevtools } from "@tanstack/solid-router-devtools";
import { render } from 'solid-js/web'
<% for(const route of routes) { %>import <%= route.jsName %> from "<%= relativePath(route.path) %>";
<% } %><% if (routes.length > 0) { %>
import Header from "./components/Header";
<% } %><% for(const integration of integrations.filter(i => i.type === 'layout' || i.type === 'provider')) { %>
import <%= integration.jsName %> from "<%= relativePath(integration.path) %>";
<% } %>

import "./styles.css";

import App from "./App.<%= jsx %>";

const rootRoute = createRootRoute({
  component: () => (
    <>
    <% for(const integration of integrations.filter(i => i.type === 'provider')) { %>
      <<%= integration.jsName %>>
    <% } %>
      <% if (routes.length > 0) { %><Header /><% } %>
      <Outlet />
      <TanStackRouterDevtools />
      <% for(const integration of integrations.filter(i => i.type === 'layout')) { %>
        <<%= integration.jsName %> />
      <% } %>
      <% for(const integration of integrations.filter(i => i.type === 'provider').reverse()) { %>
        </<%= integration.jsName %>>
      <% } %>
      </>
  ),
});

const indexRoute = createRoute({
  getParentRoute: () => rootRoute,
  path: "/",
  component: App,
});

const routeTree = rootRoute.addChildren([indexRoute<%= routes.map(route => `, ${route.jsName}(rootRoute)`).join('') %>]);

const router = createRouter({
  routeTree,
  defaultPreload: "intent",
  scrollRestoration: true,
});
<% if (typescript) { %>
declare module '@tanstack/solid-router' {
  interface Register {
    router: typeof router
  }
}
<% } %>
function MainApp() {
  return (
    <>
      <RouterProvider router={router} />
    </>
  )
}

const rootElement = document.getElementById('app')
if(rootElement) {
  render(() => <MainApp />, rootElement)
}
<% } else {
  
/// File Router
%>import { RouterProvider, createRouter } from '@tanstack/solid-router'
import { render } from 'solid-js/web'<% if (addOnEnabled.sentry) { %>
import * as Sentry from '@sentry/solid'
<% } %>

import { routeTree } from './routeTree.gen'
import './styles.css'

const router = createRouter({
  routeTree,
  defaultPreload: 'intent',
  scrollRestoration: true,
  defaultPreloadStaleTime: 0,
})

<% if (addOnEnabled.sentry) { %>
Sentry.init({
  dsn: import.meta.env.VITE_SENTRY_DSN,
  integrations: [Sentry.replayIntegration()],

  // Setting a sample rate is required for sending performance data.
  // We recommend adjusting this value in production, or using tracesSampler
  // for finer control.
  tracesSampleRate: 1.0,
  replaysSessionSampleRate: 1.0, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
  replaysOnErrorSampleRate: 1.0,
});
<% } %>

declare module '@tanstack/solid-router' {
  interface Register {
    router: typeof router
  }
}

function App() {
  return (
    <>
      <RouterProvider router={router} />
    </>
  )
}

const rootElement = document.getElementById('app')
if(rootElement) {
  render(() => <App />, rootElement)
}
<% } %>